package com.yss.reportworld.enums;

import com.yss.common.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum ReportWorldFileNameEnum implements BaseEnum<String> {
    REPORT_TABLE_FILENAME_JSON("tableinfo", "txt"),
    REPORT_JSON("report", "txt"),
    MODULAR_JSON("modular", "txt"),
    CUSTOMER_JSON("customer", "txt"),
    SQL_JSON("sql", "txt"),
    DATABASE_JSON("database", "txt"),
    DATABASE_SQL("database_sql", "sql"),
    SQL_SCRIPT("sql_script", "sql"),
    DEMAND_BUG("demand_bug", "txt"),
    VERSION("version", "txt"),
    COMPARECONFIG("compareconfig", "txt"),
    /**
     * 报表部署包文件
     */
    TP_REP_BASIC_SUBMIT("TP_REP_BASIC_SUBMIT", "TpRepBasicSubmit"),
    TP_REP_BASIC_INFO("TP_REP_BASIC_INFO", "TpRepBasicInfo"),
    TP_REP_BASIC_STYLE("TP_REP_BASIC_STYLE", "TpRepBasicStyle"),
    TP_REP_BASIC_REPORT_MODEL("TP_REP_BASIC_REPORT_MODEL", "TpRepBasicReportModel"),
    TP_REP_BASIC_MICRO_VARIABLE("TP_REP_BASIC_MICRO_VARIABLE", "TpRepBasicMicroVariable"),
    TP_REP_BASIC_COL_MODEL("TP_REP_BASIC_COL_MODEL", "TpRepBasicColModel"),
    TP_GL_EXHIB_DATADICT("TP_GL_EXHIB_DATADICT", "TpGlExhibDatadict"),
    TC_REP_PARA("TC_REP_PARA", "TcRepPara"),
    TC_REP_DATASET("TC_REP_DATASET", "TcRepDataset"),
    TP_REP_BASIC_PARAM("TP_REP_BASIC_PARAM", "TpRepBasicParam");
    private final String code;
    private final String desc;

    public static ReportWorldFileNameEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        ReportWorldFileNameEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
